<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title></title>
    <meta name="keywords" content="">
    <meta name="description" content="">
    <link rel="shortcut icon" href="favicon.ico"> 
	<link href="__PUBLIC__/admin/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="__PUBLIC__/admin/css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="__PUBLIC__/admin/css/style.css?v=4.1.0" rel="stylesheet">
    <link href="__PUBLIC__/admin/css/double-date.css" rel="stylesheet">
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/uploadify/uploadify.css"/>
    <script src="__PUBLIC__/admin/js/jquery.min.js?v=2.1.4"></script>
    <script src="__PUBLIC__/admin/js/double-date.js"></script>
    <script type="text/javascript" charset="utf-8" src="__PUBLIC__/ueditor/ueditor.config.js"></script>
    <script type="text/javascript" charset="utf-8" src="__PUBLIC__/ueditor/ueditor.all.js"> </script>
    <script type="text/javascript" charset="utf-8" src="__PUBLIC__/ueditor/lang/zh-cn/zh-cn.js"></script>
</head>




<script>
var pnum = {$pnum};
var filter = {$filter};
{if condition="(!isset($search)) OR (!$search)"}
var url = "/{$Request.module}/coupon/lst/filter/"+filter+".html?page="+pnum;
{else/}
var url = "/{$Request.module}/coupon/search.html?page="+pnum;
{/if}
var updateUrl = "{:url('coupon/edit')}";
</script>

<body class="gray-bg">
<style>
input.error{
	border:1px solid red;
}
span.error{
	padding-top:10px;
	color: #f00;
	font-size:12px;
}
</style>

    <div class="wrapper wrapper-content">
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>编辑优惠券</h5>
                    </div>
                    <div class="ibox-content">
                        <form method="post" class="form-horizontal" id="form">
                            <div class="form-group">
                                <label class="col-sm-2 control-label">满金额：</label>
                                <div class="col-sm-6">
                                    <input type="text" name="man_price" value="{$coupons.man_price}" class="form-control">
                                </div>
                                 <label class="col-sm-1" style="padding-top:7px; color:#F00; font-size:16px;">*</label>
                            </div>
                            <div class="hr-line-dashed"></div>
                            
                            <div class="form-group">
                                <label class="col-sm-2 control-label">减金额：</label>
                                <div class="col-sm-6">
                                    <input type="text" name="dec_price" value="{$coupons.dec_price}" class="form-control">
                                </div>
                                 <label class="col-sm-1" style="padding-top:7px; color:#F00; font-size:16px;">*</label>
                            </div>
                            <div class="hr-line-dashed"></div>
                            
                            <div class="form-group">
                                <label class="col-sm-2 control-label">有效日期：</label>
                                <div class="col-sm-8">
                                    <div class="date date1 fl" id="from" style="float:left; margin-right:25px;">
                                                                                                    开始日期：<input type="text" name="start_time" readonly="readonly" value="{:date('Y-m-d',$coupons['start_time'])}" class="date-check">
                                    </div>
                                    <div class="date fr" id="to" style="float:left;">
                                                                                                    结束日期：<input type="text" name="end_time" readonly="readonly" value="{:date('Y-m-d',$coupons['end_time'])}" class="date-check">
                                    </div>
                                </div>
                                <label class="col-sm-1" style="padding-top:7px; color:#F00; font-size:16px;">*</label>
                            </div>
                            <div class="hr-line-dashed"></div>
                            
                            <div class="form-group">
                                <label class="col-sm-2 control-label">是否上架：</label>
                                <div class="col-sm-6">
                                        <label class="radio-inline"><input type="radio" name="onsale" {if condition="$coupons['onsale'] eq 1"}checked="checked"{/if} value="1">上架</label>
                                        <label class="radio-inline"><input type="radio" name="onsale" {if condition="$coupons['onsale'] eq 0"}checked="checked"{/if} value="0">下架</label>
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                            
                            <div class="form-group">
                                <label class="col-sm-2 control-label">放入回收站：</label>
                                <div class="col-sm-6">
                                        <label class="radio-inline"><input type="radio" name="is_recycle" {if condition="$coupons['is_recycle'] eq 1"}checked="checked"{/if} value="1">是</label>
                                        <label class="radio-inline"><input type="radio" name="is_recycle" {if condition="$coupons['is_recycle'] eq 0"}checked="checked"{/if} value="0">否</label>
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                            
                            <div class="form-group">
                                <label class="col-sm-2 control-label">排序：</label>
                                <div class="col-sm-6">
                                    <input type="text" name="sort" value="{$coupons.sort}" class="form-control">
                                </div>
                            </div>						
                            <div class="hr-line-dashed"></div>

                           
                           <input name="id" type="hidden" value="{$coupons.id}">
                                                 
                            <div class="form-group">
                                <div class="col-sm-4 col-sm-offset-2">
                                    <button class="btn btn-primary" type="submit" id="doSubmit" style="margin-right:20px;">保存内容</button>
                                    <button type="reset" class="btn btn-default">重置</button>
                                </div>
                            </div>
                            
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>


    <!-- 全局js -->
    <script src="__PUBLIC__/admin/js/bootstrap.min.js?v=3.3.6"></script>
    <!-- 自定义js -->
    <script type="text/javascript" src="__PUBLIC__/uploadify/jquery.uploadify.min.js"></script>
    <script src="__PUBLIC__/admin/js/plugins/layer/layer.min.js"></script>
    <script src="__PUBLIC__/admin/js/plugins/validate/jquery.validate.min.js"></script>	
    <!-- iCheck -->
    <script src="__PUBLIC__/admin/js/plugins/iCheck/icheck.min.js"></script>
    <script src="__PUBLIC__/admin/js/common/ajax.js"></script>

	<script>
    	$(function(){  
        	jQuery.validator.addMethod("date", function(value, element){   
        	    var tel = /^([0-9]{4})-([0-9]{2})-([0-9]{2})$/;
        	    return this.optional(element) || (tel.test(value));
        	}, "日期格式不正确");
            
    	    var icon = "<i class='fa fa-times-circle'></i>&nbsp;&nbsp;";
        	$('#form').validate({
	        	errorElement : 'span',
	        	debug: true,//只验证不提交表单
	            //layer ajax提交表单
	            submitHandler:function(){
	                // 序列化 表单数据 后提交 ，太简洁了
	                post(updateUrl,'POST',$('#form').serialize(),1);
	                return false;
	            },//这是关键的语句，配置这个参数后表单不会自动提交，验证通过之后会去调用的方法
	                
	        	rules:{
	        		man_price:{required:true},
	        		dec_price:{required:true},
	        		start_time:{
	        			required:true,
	        			date:true
	        		},
	        		end_time:{
	        			required:true,
	        			date:true
	        		}
	        	},
	        		
	        	messages:{
	        		man_price:{required:icon+'必填'},
	        		dec_price:{required:icon+'必填'},
	        		start_time:{
	        			required:icon+'必填',
	        			date:icon+'日期格式错误'
	        		},
	        		end_time:{
	        			required:icon+'必填',
	        			date:icon+'日期格式错误'
	        		}
	        	}
            });
      });
    	
      function cl(){
    	  location.href = url;
      }
    </script>

</body>
</html>